package com.compunit.composite.core.interfaces;

import java.net.URL;

import com.compunit.composite.core.CompUnit;
import com.compunit.composite.core.interfaces.cx.ICxImporter;

/**
 * <code>IAssembler</code> defines the interface of an
 * utility unit that is responsible for assembling the
 * components defined by the imported cx information.
 *
 * @author Yi Wang (Neakor)
 * @version Creation date: 11-13-2009 18:09 EST
 * @version Modified date: 11-13-2009 18:27 EST
 */
public interface IAssembler {

	/**
	 * Assemble the component implementations defined by
	 * the given cx importer cached information.
	 * @param importer The <code>ICxImporter</code>.
	 * @param jar The <code>URL</code> to the component
	 * class jar file.
	 * @return The <code>Iterable</code> of all instances
	 * of <code>CompUnit</code> assembled.
	 * @throws ClassNotFoundException If the information
	 * cached in the cx importer does not match the data
	 * in the jar file.
	 * @throws InstantiationException If component cannot
	 * be instantiated.
	 * @throws IllegalAccessException If component class
	 * object cannot be accessed correctly.
	 */
	public Iterable<CompUnit> assemble(final ICxImporter importer, final URL jar) throws ClassNotFoundException, InstantiationException, IllegalAccessException;
	
	/**
	 * Retrieve all the assembled component instances
	 * in the correct activation order.
	 * @return The <code>Iterable</code> of all instances
	 * of <code>CompUnit</code> assembled.
	 */
	public Iterable<CompUnit> getComponents();
	
	/**
	 * Clear all cached assembly information.
	 */
	public void cleanup();
}
